var recIdArray = [];
var workerstateArray = [];

$(function(){
	selectGroups();
	getWorkerType();
});

var tableData = {
	url : ctp + "/exitSettlementController/exitSettlementSearch.shtml",
	hidden : [ "workerstate=WORKER_STATE" ],
	propertys : [ "NAME","JOBNO","WORKTYPE","GROUPNAME","SALARY","CHARGETYPE_NAME","UNITPAY","PAYFORM","WORKHOURS","WORKQUANTITY","SHOULDGIVE","REALGIVE","NOGIVE","WORKER_STATE_CHAR"],
	globalCheck : [["recId", recIdArray],["workerstate", workerstateArray]],
	startLoad : function() {
		getListData(this);
	}
};
function searchData(curr) {
	setTagAndValue("form1", "curr", curr);
	tableData.startLoad();
}
$(document).ready(function() {
	searchData();
});

function attendanceUpdate(recId) {
	layui.layer.open({
        type: 2,
        area: ['1000px', '550px'],
        title: "修改考勤排班",
        fixed: false,
        maxmin: false,
        content: ctp + "/attendanceController/attendanceUpdate.shtml?recId="+recId
    });
}

//导出系统用户
function exportConfirm(recId){
	var formSerialize =$("#form1").serialize();
	jconfirm("exportData('"+formSerialize+"')","确认要导出考勤数据吗？");	
}
function exportData(formSerialize){
	location.href=ctp+"/attenRecordController/exportAttendance.shtml?"+formSerialize;
}

function exitpayApply(){
	var workerstate = getCheckIds(null, "workerstate");
	if(workerstate.indexOf("2") >= 0){
		jalert("你选择的工人中，存在已提交过申请的，请确认！");
		return;
	}
	if(workerstate.indexOf("3") >= 0){
		jalert("你选择的工人中，存在已退场的，请确认！");
		return;
	}
	
	var recIds = getCheckIds();
	if(recIds == '' || recIds == null){
		jalert("请选择结算工资的员工！");
		return;
	}
	if(recIds.length > 1024){
		jalert("你选择的员工数量过多，请分批次处理，建议一次处理25个最佳！");
		return;
	}
	
	
	layui.layer.open({
        type: 2,
        area: ['1100px', '500px'],
        title: "退场结算申请",
        fixed: false,
        maxmin: false,
        content: ctp + "/exitSettlementController/pageEditExitSettlement.shtml?workerId=" + recIds
    });
	
//	jconfirm("apply()","确认提交结算申请吗？");	
}


function selectGroups(){
    $.ajax({
        url: ctp + "/groupController/selectGroups.shtml", 
        data: {},
        type: "POST", 
        cache : false, 
        dataType: "json",
        success: function(data) {
            var list = data.list; 
			var $str='';
			$str +='<select class="smart-body_select" name="groupid" id="groupid">';
			$str +='<option value="">全部</option>';
        	for (var i = 0; i < list.length; i++) {
        		var l = list[i];
        		$str+='<option value="'+l.REC_ID+'">'+l.NAME+'</option>';
        	}
        	$str+='</select>';
        	$('#group').append($str);
        }
    });
}


function getWorkerType() {
	$.ajax({
		url : ctp + "/sysdictController/getDictListByType.shtml",
		data : {
			dicType : 'WORKER_TP'
		},
		type : "POST",
		cache : false,
		dataType : "json",
		success : function(data) {
			var list = data.list;
			var $str = '';
			$str += '<option value="">全部</option>';
			for (var i = 0; i < list.length; i++) {
				var l = list[i];
				$str += '<option value="' + l.rec_value + '">' + l.rec_value
						+ '</option>';
			}
			$('#workeType').html($str);
		}
	});
}

function promptInfo(){
	recIdArray.splice(0,recIdArray.length);
	workerstateArray.splice(0,workerstateArray.length);
	jalert9("结算申请提交成功！");
}